package cn.ly.array;

public class LowArrayApp {
	
	public static void main(String[] args) {
		
		LowArray arr = new LowArray(100);
		
		int nElems = 0;
		int j;
		
		arr.setElem(0, 77);
		arr.setElem(1, 99);
		arr.setElem(2, 44);
		arr.setElem(3, 55);
		arr.setElem(4, 66);
		arr.setElem(5, 88);
		arr.setElem(6, 99);
		arr.setElem(7, 0);
		arr.setElem(8, 11);
		arr.setElem(9, 22);
		nElems = 10;
		
		//显示所有
		for(j = 0; j < nElems; j++){
			System.out.print(arr.getElem(j) + " ");
		}
		
		System.out.println();
		
		//查找一个
		int searchKey = 66;
		for(j = 0; j < nElems; j++){
			if(arr.getElem(j) == searchKey){
				break;
			}
		}
		
		if(j == 10){
			System.out.println("Can't find " + searchKey);
		}else{
			System.out.println("Found " + searchKey + " at arr[" + j + "]");
		}
		
		//删除一个
		searchKey = 55;
		for(j = 0; j < nElems; j++){
			if(arr.getElem(j) == searchKey){
				break;
			}
		}
		
		for(; j < nElems; j++){
			arr.setElem(j, arr.getElem(j+1));
		}
		
		nElems = 9;
		
		//显示所有
		for(j = 0; j < nElems; j++){
			System.out.print(arr.getElem(j) + " ");
		}
	}

}
